﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace SMSRobot
{
    class MainWinContext : INotifyPropertyChanged
    {

        #region INotifyPropertyChanged 成员

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        /// <summary>
        /// 串口是否打开
        /// </summary>
        public bool isOpend = false;
        public bool IsOpend
        {
            get { return isOpend; }
            set
            {
                if (value != this.isOpend)
                {
                    this.isOpend = value;
                    NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// 串口是否打开
        /// </summary>
        public bool isEnabledOpen = true;
        public bool IsEnabledOpen
        {
            get { return isEnabledOpen; }
            set
            {
                if (value != this.isEnabledOpen)
                {
                    this.isEnabledOpen = value;
                    NotifyPropertyChanged();
                }
            }
        }
        ///// <summary>
        ///// 是否正在发送中...
        ///// </summary>
        //public bool isSending = false;
        //public bool IsSending
        //{
        //    get { return isSending; }
        //    set
        //    {
        //        if (value != this.isSending)
        //        {
        //            this.isSending = value;
        //            NotifyPropertyChanged();
        //        }
        //    }
        //}
        ///// <summary>
        ///// 是否能发送
        ///// </summary>
        //public bool isEnabledSend = true;
        //public bool IsEnabledSend
        //{
        //    get { return isEnabledSend; }
        //    set
        //    {
        //        if (value != this.isEnabledSend)
        //        {
        //            this.isEnabledSend = value;
        //            NotifyPropertyChanged();
        //        }
        //    }
        //}
        

        /// <summary>
        /// 是否正在工作
        /// </summary>
        public bool isWorking = false;
        public bool IsWorking
        {
            get { return isWorking; }
            set
            {
                if (value != this.isWorking)
                {
                    this.isWorking = value;
                    NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// 是否能启动工作
        /// </summary>
        public bool isEnabledWork = true;
        public bool IsEnabledWork
        {
            get { return isEnabledWork; }
            set
            {
                if (value != this.isEnabledWork)
                {
                    this.isEnabledWork = value;
                    NotifyPropertyChanged();
                }
            }
        }

        public string stateText = "准备就绪!";
        public string StateText
        {
            get { return stateText; }
            set
            {
                if (value != this.stateText)
                {
                    this.stateText = value;
                    NotifyPropertyChanged();
                }
            }
        }
        public bool autoStart = false;
        public bool AutoStart
        {
            get { return autoStart; }
            set
            {
                if (value != this.autoStart)
                {
                    this.autoStart = value;
                    NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// 接收数量
        /// </summary>
        public int recived = 0;
        public int Recived
        {
            get { return recived; }
            set
            {
                if (value != this.recived)
                {
                    this.recived = value;
                    NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// 发送数量
        /// </summary>
        public int sent = 0;
        public int Sent
        {
            get { return sent; }
            set
            {
                if (value != this.sent)
                {
                    this.sent = value;
                    NotifyPropertyChanged();
                }
            }
        }

        #endregion
    }
}
